package com.androidx.p013lv.base.recycler;

import androidx.recyclerview.widget.RecyclerView;
import com.androidx.p013lv.base.listener.ItemClickListener;
import com.androidx.p013lv.base.listener.ItemLongClickListener;
import com.androidx.p013lv.base.recycler.BaseRecyclerHolder;
import java.util.ArrayList;
import java.util.List;

/* renamed from: com.androidx.lv.base.recycler.BaseRecyclerAdapter */
public abstract class BaseRecyclerAdapter<D, H extends BaseRecyclerHolder> extends RecyclerView.Adapter<H> {
    protected ItemClickListener itemListener;
    protected List<D> list;
    protected ItemLongClickListener longListener;

    public abstract void MyHolder(H h, int i);

    public void setItemListener(ItemClickListener itemClickListener) {
        this.itemListener = itemClickListener;
    }

    public void setLongListener(ItemLongClickListener itemLongClickListener) {
        this.longListener = itemLongClickListener;
    }

    public BaseRecyclerAdapter() {
        this.list = null;
        this.list = new ArrayList();
    }

    public void onBindViewHolder(H h, int i) {
        ItemClickListener itemClickListener = this.itemListener;
        if (itemClickListener != null) {
            h.setItemListener(itemClickListener, i);
        }
        ItemLongClickListener itemLongClickListener = this.longListener;
        if (itemLongClickListener != null) {
            h.setItemListener(itemLongClickListener, i);
        }
        MyHolder(h, i);
    }

    public void setData(List<D> list2) {
        if (list2 != null) {
            this.list.clear();
            this.list.addAll(list2);
            notifyDataSetChanged();
        }
    }

    public void setDataInEnd(D d) {
        if (d != null) {
            this.list.add(d);
            notifyDataSetChanged();
        }
    }

    public void setDatasInEnd(List<D> list2) {
        if (list2 != null && list2.size() != 0) {
            this.list.addAll(list2);
            if (this.list.size() > 0) {
                notifyItemInserted(this.list.size() - 1);
            }
        }
    }

    public void setDatasInStart(List<D> list2) {
        if (list2 != null && list2.size() != 0) {
            this.list.addAll(0, list2);
            notifyDataSetChanged();
        }
    }

    public void setDataInStart(D d) {
        if (d != null) {
            this.list.add(0, d);
            notifyDataSetChanged();
        }
    }

    public void clear() {
        this.list.clear();
        notifyDataSetChanged();
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public int getItemCount() {
        return this.list.size();
    }

    public D getDataInPosition(int i) {
        List<D> list2 = this.list;
        if (list2 == null || list2.size() < i) {
            return null;
        }
        return this.list.get(i);
    }

    public List<D> getData() {
        return this.list;
    }

    public D getLastDataInPosition() {
        List<D> list2 = this.list;
        if (list2 == null || list2.size() == 0) {
            return null;
        }
        return this.list.get(this.list.size() - 1);
    }
}
